from datetime import datetime

from lenovo import settings


def jwt_payload_handler(user):
    """
    Generate JWT payload
    """
    payload = {
        'user_id': user.id,
        'email': user.email,
        'username': user.nickname,
        'exp': datetime.utcnow() + settings.SIMPLE_JWT['ACCESS_TOKEN_LIFETIME']
    }
    return payload